package com.feihao.zhou.demoTest2;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class Test2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        //创建文件字节输入流读取配置文件:
        FileInputStream fis = new FileInputStream(
                "D:\\IdeaProjects\\Job-code\\day17-code-Reflect\\src\\com\\feihao\\zhou\\demoTest2\\prop.properties");

        //创建Properties集合存储读取到的键值对:
        Properties pro = new Properties();
        pro.load(fis);

        //获取ClassName:
        String className = pro.getProperty("ClassName");
        //
        //获取class对象:
        Class aClass = Class.forName(className);

        //获取方法:
        String methodName = pro.getProperty("MethodName");

        //创建对象:
        Object o = aClass.newInstance();

        System.out.println(o instanceof Teacher);
        Person person = (Person) o;   //向下转型!!!
        person.eat();
    }
}
